package com.stn.zjx.givingtreasure.activity.bi;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.came.viewbguilib.ButtonBgUi;
import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;
import com.stn.zjx.givingtreasure.R;
import com.stn.zjx.givingtreasure.base.BaseActivity;
import com.stn.zjx.givingtreasure.event.BackupMnEvent;
import com.stn.zjx.givingtreasure.event.NetWorkEvent;
import com.stn.zjx.givingtreasure.utils.ToolsUtils;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class BackUpMnemonicActivity extends BaseActivity {


    public String mnemonic = "";
    @BindView(R.id.back_bt)
    RelativeLayout backBt;
    @BindView(R.id.action_title)
    TextView actionTitle;
    @BindView(R.id.web_title)
    TextView webTitle;
    @BindView(R.id.action_add_bt)
    RelativeLayout actionAddBt;
    @BindView(R.id.action_refresh)
    RelativeLayout actionRefresh;
    @BindView(R.id.exit)
    RelativeLayout exit;
    @BindView(R.id.sure_bt)
    TextView sureBt;
    @BindView(R.id.share_bt)
    RelativeLayout shareBt;
    @BindView(R.id.more_bt)
    RelativeLayout moreBt;
    @BindView(R.id.release_bt)
    ButtonBgUi releaseBt;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.mnemonic_edit)
    EditText mnemonicEdit;
    @BindView(R.id.next_bt)
    ButtonBgUi nextBt;
    @BindView(R.id.twinkling_refresh)
    TwinklingRefreshLayout twinklingRefresh;

    @Override
    public void networkStatus(NetWorkEvent netWorkEvent) {

    }

    @Override
    public void initComponent() {
        actionTitle.setText(getString(R.string.backupwallet));
        mnemonic = getIntent().getStringExtra("mnemonic");
        mnemonicEdit.setText(mnemonic);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_backup_mnemonic);
        ButterKnife.bind(this);
        initComponent();
    }


    @OnClick({R.id.back_bt,R.id.next_bt})
    public void onViewClicked(View view) {

        switch (view.getId()) {
            case R.id.back_bt:
                finish();
                break;
            case R.id.next_bt:
                 if(ToolsUtils.copyKeybroadContent(getApplicationContext(),mnemonic)){
                    showToast(getString(R.string.already_copy_content));
                 }else{
                     showToast(getString(R.string.db_error));
                 }
                BackupMnEvent event=new BackupMnEvent();
                EventBus.getDefault().post(event);
                finish();
                break;
        }
    }


}
